<script setup>
import GoodsSelect from "@/components/GoodsSelect.vue";
import {useCreate} from "@/store/useCreate.js";
import {useUser} from "@/store/useUser.js";
import {PictureFilled} from "@element-plus/icons-vue";

const createStore = useCreate()
const userStore = useUser()
const userInfo = userStore.getUserInfo
</script>

<template>
  <div class="info">
    <div class="info-left">
      <div class="swiper-box">
        <el-carousel style="height: 474px;">
          <el-carousel-item style="height: 474px;" v-for="item in createStore.formData.coverPicList.filter(item=> item && item.url)" :key="item">
            <el-image v-if="item.type === 1" class="swiper-img" :src="item.url" fit="contain">
              <div class="image-slot">
                <el-icon><PictureFilled /></el-icon>
              </div>
            </el-image>
            <video  v-if="item.type === 2" :src="item.url" style="width: 100%; height: 100%" controls></video>
          </el-carousel-item>
        </el-carousel>
      </div>
      <!--					-->
      <p class="goods-name">{{createStore.formData.goodsName}}</p>
      <div class="goods-cate">
        <span class="class">所属品类：{{createStore.formData.typeName}}</span>
        <span v-for="item of createStore.formData.labelList">{{item.label}}</span>
      </div>
      <div class="about-info">
        <p class="title">
          <span>关于卖家</span>
          <a>进入主页 <img src="@/assets/check-more-icon-2.png" alt=""></a>
        </p>
        <div class="user-main-info">
          <img class="head" v-if="userInfo && userInfo.avatar" :src="userInfo.avatar" alt="">
          <img  class="head" v-else src="@/assets/logo-small.png" alt="">
          <div class="name-info">
            <p class="name-line">
              <span class="name">{{userInfo.nickName || userInfo.phonenumber}}</span>
              <img src="@/assets/follow-icon-active.png" alt="">
              <span class="x-status">已关注</span>
            </p>
          </div>
          <div class="x-leve">
            <p class="x-title">信用等级</p>
            <p class="x-status">{{userInfo.buyerInfo.creditLevel || 0}}</p>
            <p class="status-num">分值 {{userInfo.buyerInfo.creditScore || 0}}</p>
          </div>
          <span class="line"></span>
          <div class="x-leve">
            <p class="x-title">总销量</p>
            <p class="x-status">{{userInfo.buyerInfo.orderCount}}</p>
            <p class="status-num">准时交付率 {{100}}%</p>
          </div>
        </div>
      </div>
    </div>
    <div class="info-right">
      <div class="user-info">
        <div class="head">
          <img v-if="userInfo && userInfo.avatar" :src="userInfo.avatar" alt="">
          <img v-else src="@/assets/logo-small.png" alt="">
          <span></span>
        </div>
        <div class="info-data">
          <div class="name-line">
            <span class="name">{{userInfo.nickName || userInfo.phonenumber}}</span>
            <span class="follow"><img src="@/assets/follow-icon-active.png" alt="">已关注</span>
          </div>
          <div class="user-data">
            <div class="online">
              <span class="status">在线</span>
              <span> · 3分钟内回复率 100%</span>
            </div>
            <img class="star" src="@/assets/mack-icon.png" alt="">
            <span class="star-num">{{userInfo.buyerInfo.commentRate}}</span>
            <span class="star-len">({{userInfo.buyerInfo.goodsCommentCount || 0}})</span>
          </div>
        </div>
      </div>
      <GoodsSelect/>
    </div>
  </div>
  <!--	服务介绍	-->
  <div class="service-details">
    <div class="service-tab">
      <span class="active">服务详情</span>
    </div>
  </div>
  <div class="imgs">
    <el-image v-for="(item,index) of createStore.formData.introduce.introduce.split(',')" :key="index" class="img-show" :src="item">
      <div class="image-slot">
        <el-icon><PictureFilled /></el-icon>
      </div>
    </el-image>
  </div>
</template>

<style scoped lang="scss">
.info{
  padding-top: 10px;
  display: flex;
}
.content{
  max-width: 1200px;
  margin: 0 auto;
}
.info-left{
  flex: 1.4;
}
.swiper-box{
  width: 100%;
  height: 474px;
  position: relative;
}
.swiper-img{
  width: 100%;
  height: 474px;
  border-radius: 24px;
}
.goods-name{
  color: #191E28;
  font-size: 28px;
  font-weight: bold;
  margin-top: 32px;
  margin-bottom: 16px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  max-width: 734px;
}
.goods-cate{
  display: flex;
  margin-bottom: 32px;
  span{
    padding: 2px 8px;
    background: #FFFFFF;
    border-radius: 4px 4px 4px 4px;
    border: 1px solid rgba(25,30,40,0.08);
    font-size: 12px;
    margin-right: 8px;
  }
  .class{
    color: #008571;
    background: rgba(0,133,113,0.08);
    border: 1px solid rgba(0,133,113,0.08);
  }
}
.about-info{
  display: flex;
  flex-direction: column;
  .title{
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    span{
      color: #191E28;
      font-size: 20px;
      font-weight: bold;
    }
    a{
      display: flex;
      align-items: center;
      color: #191E28;
      text-decoration: none;
      img{
        width: 7px;
        height: 14px;
        margin-left: 6px;
        position: relative;
        top: 1px
      }
    }
  }
}
.user-main-info{
  display: flex;
  align-items: center;
  background: rgba(25,30,40,0.02);
  border-radius: 12px 12px 12px 12px;
  padding: 24px;
  box-sizing: border-box;
  .head{
    width: 60px;
    flex: 0 0 60px;
    height: 60px;
    border-radius: 100%;
    margin-right: 12px;
  }
  .name-info{
    flex: 1;
    display: flex;
    flex-direction: column;
    .name-line{
      display: flex;
      align-items: center;
      margin-bottom: 12px;
      .name{
        color: #191E28;
        font-weight: bold;
        margin-right: 12px;
      }
      img{
        width: 16px;
        height: 16px;
        margin-right: 4px;
      }
      .x-status{
        color: #191E28;
      }
    }
    .bzj{
      display: flex;
      align-items: center;
      img{
        width: 16px;
        height: 16px;
      }
      span{
        color: rgba(255, 140, 29, 1);
      }
    }
  }
  .line{
    width: 1px;
    height: 40px;
    background: rgba(25,30,40,0.08);
    margin: 0 24px;
  }
  .x-leve{
    display: flex;
    flex-direction: column;
    .x-title{
      color: rgba(25,30,40,0.48);
      font-size: 12px;
      margin-bottom: 2px;
    }
    .x-status{
      color: #191E28;
      font-size: 18px;
      font-weight: bold;
      margin-bottom: 2px;
    }
    .status-num{
      color: rgba(25,30,40,0.48);
      font-size: 12px;
    }
  }
}
.info-right{
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: 36px;
}
.user-info{
  display: flex;
  box-sizing: border-box;
  .head{
    position: relative;
    width: 56px;
    height: 56px;
    img{
      width: 100%;
      height: 100%;
    }
    span{
      position: absolute;
      right:0;
      bottom:0;
      width: 12px;
      height: 12px;
      background: #1DBF73;
      border-radius: 100%;
      border: 2px solid #FFFFFF;
    }
  }
  .info-data{
    flex: 1;
    padding-left: 12px;
  }
  .name-line{
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    .name{
      color: #191E28;
      font-size: 20px;
      font-weight: bold;
      margin-right: 12px;
    }
    .follow{
      display: flex;
      align-items: center;
      cursor: pointer;
      img{
        width: 16px;
        height: 16px;
        margin-right: 4px;
        position: relative;
        top: 2px;
      }
      span{
        color: rgba(25,30,40,0.6);
      }
    }
  }
  .user-data{
    display: flex;
    align-items: center;
    .online{
      flex: 1;
      span{
        font-size: 12px;
        color: rgba(25,30,40,0.48);
      }
      .status{
        color: #1DBF73;
      }
    }
    .star{
      width: 16px;
      height: 16px;
      margin-right: 4px;
    }
    .star-num{
      line-height: 16px;
      color: #191E28;
      font-weight: bold;
    }
    .star-len{
      color: rgba(25,30,40,0.48);
    }
  }
}
.service-details{
  margin-top: 32px;
  .service-tab{
    display: flex;
    border-bottom: 1px solid #EDEDEE;
    span{
      color: #191E28;
      font-size: 20px;
      padding: 12px 24px;
      &.active{
        color: #1DBF73;
        position: relative;
        &:before{
          content: '';
          position: absolute;
          bottom: 0;
          left: 50%;
          margin-left: -17px;
          width: 34px;
          height: 2px;
          background: #1DBF73;
        }
      }
    }
  }
}
.service-details{
  margin-top: 32px;
  .service-tab{
    display: flex;
    border-bottom: 1px solid #EDEDEE;
    span{
      color: #191E28;
      font-size: 20px;
      padding: 12px 24px;
      &.active{
        color: #1DBF73;
        position: relative;
        &:before{
          content: '';
          position: absolute;
          bottom: 0;
          left: 50%;
          margin-left: -17px;
          width: 34px;
          height: 2px;
          background: #1DBF73;
        }
      }
    }
  }
}
.imgs{
  margin-top: 20px;
  img{
    width: 100%;
  }
}
</style>